class Fetcher 
  def self.logger
    @@logger ||= Logger.new(File.join(RAILS_ROOT,"log","fetcher.log"))
  end

  def logger
    self.class.logger
  end

  def fetch_matches
    logger.info "#{Time.now} start fetch matches"
    matches_count = Sport.fetch_matches
    logger.info "#{matches_count} matches was fetched."
  end

  def fetch_results
    logger.info "#{Time.now} start fetch results"
    matches = Sport.fetch_results
    logger.info "#{matches.size} was played."
    next_match = Match.next_match
    logger.info "next : #{next_match.info}"
  end

  def self.start
    fetcher = self.new
    fetcher.fetch_matches
    fetcher.fetch_results
  end
end
